<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var time = 3;
     var timer = setInterval(function(){
        if(time == 0){
            console.log('全军出击');
            clearInterval(timer);
        }else{
            console.log('敌军还有'+time+'秒到达战场');
        time--;
        }
    },1000)
    </script>
</body>
</html>